package com.ijunfu.thread._04_thread_pool;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.stream.IntStream;

/**
 *
 * @title  : 创建线程的第四种方式：线程池
 * @author : ijunfu <ijunfu@163.com>
 * @date   : 2023/10/23 13:35
 * @version: 1.0
 * @motto  : 位来可期 - 世界很大，我想看看
 *
 */
@Slf4j
public class Main {

    public static void main(String[] args) {
        // 创建线程池
        ExecutorService service = Executors.newFixedThreadPool(10);

        IntStream.range(0,20).forEach(e->service.execute(()->log.info("No.{} running...", e)));

        // 销毁线程池
        service.shutdown();
    }
}
